package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.purchase.RCBasePurchaseOrderAccept;
import com.shrct.businessprocess.purchase.RCBasePurchasePayRequest;
import com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptPay;
import com.shrct.businessprocess.purchase.impl.RCBasePurchaseOrderAcceptImpl;
import com.shrct.businessprocess.purchase.impl.RCBasePurchasePayRequestImpl;
import com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptPayProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPURCHASEORDERACCEPTPAY_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcpurchaseorderacceptpay")
public class RCPurchaseOrderAcceptPayImpl extends BaseModelObject implements RCPurchaseOrderAcceptPay {
  public RCPurchaseOrderAcceptPayImpl() {
    super();
  }
  
  @JoinColumn(name = "accept_id")
  @ManyToOne(targetEntity = RCBasePurchaseOrderAcceptImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBasePurchaseOrderAccept accept;
  
  public RCBasePurchaseOrderAccept getAccept() {
    return this.accept;
  }
  
  public RCPurchaseOrderAcceptPay setAccept(final RCBasePurchaseOrderAccept accept) {
    this.accept = accept;
    return this;			
    
  }
  
  @JoinColumn(name = "pay_id")
  @ManyToOne(targetEntity = RCBasePurchasePayRequestImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBasePurchasePayRequest pay;
  
  public RCBasePurchasePayRequest getPay() {
    return this.pay;
  }
  
  public RCPurchaseOrderAcceptPay setPay(final RCBasePurchasePayRequest pay) {
    this.pay = pay;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCPurchaseOrderAcceptPay setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "amount_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "amount_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "amount_exchange") ) )
  private RCProjectMoney amount = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getAmount() {
    return this.amount;
  }
  
  public RCPurchaseOrderAcceptPay setAmount(final RCProjectMoney amount) {
    this.amount = amount;
    return this;			
    
  }
  
  public static RCPurchaseOrderAcceptPay create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptPay rCPurchaseOrderAcceptPay = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderAcceptPayImpl(
    );
    objectFactory.create(rCPurchaseOrderAcceptPay);
    return rCPurchaseOrderAcceptPay;			
    
  }
  
  public static RCPurchaseOrderAcceptPay createRCPurchaseOrderAcceptPayImpl(final IObjectFactory objectFactory, final Procedure1<RCPurchaseOrderAcceptPay> init) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderAcceptPay rCPurchaseOrderAcceptPay = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderAcceptPayImpl(
    );
    objectFactory.create(rCPurchaseOrderAcceptPay);
    init.apply(rCPurchaseOrderAcceptPay);
    
    return rCPurchaseOrderAcceptPay;			
    
  }
  
  public RCPurchaseOrderAcceptPayProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptPayProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderAcceptPayProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
